import React from 'react';
import PropTypes from 'prop-types';
import StyleAvatar, { AvatarClip, AvatarImg, StatusIcon } from './style';

const Avatar = ({
    src,
    size = '48px',
    status,
    statusIconSize = '8px',
    ...rest
}) => {

    return (
        <StyleAvatar {...rest}>
            {status && <StatusIcon status={status} size={statusIconSize}></StatusIcon>}
            <AvatarClip size={size}>
                <AvatarImg src={src} alt="" />
            </AvatarClip>
        </StyleAvatar>
    )
}

Avatar.propTypes = {
    src: PropTypes.string.isRequired,
    size: PropTypes.string,
    status: PropTypes.oneOf(["online", "offline"]),
    statusIconSize: PropTypes.string,
}

export default Avatar
